package com.beichuan_travel.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.beichuan_travel.enums.ResultCode;
import com.beichuan_travel.mapper.UserMapper;
import com.beichuan_travel.model.dto.LoginDTO;
import com.beichuan_travel.model.vo.ResultVO;
import com.beichuan_travel.model.vo.UserVO;
import com.beichuan_travel.service.UserService;
import com.beichuan_travel.utils.ResponseResult;
import com.beichuan_travel.utils.WeChatUtils;
import io.swagger.annotations.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.UUID;

@Api(value = "用户接口", tags = "用户接口")
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    UserService userService;

    @Resource
    ResponseResult  responseResult;


    @ApiOperation(value = "用户登录，并返回open_id", notes = "用户登录--sora")
    @ApiResponses({
        @ApiResponse(code = 200, message = "请求成功并返回openid"),
        @ApiResponse(code = 1001, message = "登录失败")
    })
    @PostMapping("/v1/login")
    public ResultVO login(@RequestBody LoginDTO loginDTO) {
        UserVO userVO = userService.login(loginDTO);
        return userVO != null ? responseResult.ok(userVO) : responseResult.faile();
    }


}
